<template>
  <div>
      <h2>会员权益增加</h2>
      <table class="table table-bordered">
        <tbody>
          <tr>
            <td align="right">权益标题</td>
            <td><input type="text" v-model="state.RightName"></td>
          </tr>
          <tr>
            <td></td>
            <td><input type="button" value="增加" @click="ok"></td>
          </tr>
        </tbody>
      </table>
  </div>
</template>

<script setup lang="ts">


import { reactive,toRefs,onMounted } from 'vue';
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router'; 
const router = useRouter();
const route=useRoute();


let data:any=reactive({
    state:{
      RightName:''
    }
   
  });
  let {state} =toRefs(data);

const ok=()=>{
  if(state.value.RightName==''){
    alert('标题不能为空')
  }
  let obj={
    RightName:state.value.RightName,
  }
axios({
  url:'/api/one/Rightadd/Rightadd',
  method:'post',
  data:obj,
})
.then((res)=>{
  console.log(res);
  if(res.data.data>0){
      alert("成功")
      router.push('/main/memberRightList')
      
  }
  else if(res.data.data==-1){
      alert('重名')
      return;
  }
  else{
    alert('失败')
    return;
  }
})

}



</script>

<style scoped>

</style>